package com.eastseeway.radioproject.config;

import android.content.Context;

import androidx.lifecycle.LiveData;

import com.eastseeway.radioproject.base.BaseRepository;
import com.eastseeway.radioproject.database.RadioProjectDatabase;
import com.eastseeway.radioproject.database.UserInfoDao;
import com.eastseeway.radioproject.entities.BaseResponse;
import com.eastseeway.radioproject.entities.BeanDeviceInfo;
import com.eastseeway.radioproject.entities.UserInfo;
import com.eastseeway.radioproject.retrofit.RetrofitClient;
import com.eastseeway.radioproject.utils.SPHelper;

import retrofit2.Callback;

public class ConfigRepository extends BaseRepository {
    private final UserInfoDao mUserInfoDao;

    public ConfigRepository(Context context) {
        mUserInfoDao = RadioProjectDatabase.getInstance(context).getUserInfoDao();
    }

    public LiveData<UserInfo> queryAdmin(){
        return mUserInfoDao.queryAdmin();
    }

    public void updateOperationParamsIsEmpty(UserInfo userInfo){
        executorService.submit(()->{
           mUserInfoDao.updateOperationParamsIsEmpty(userInfo.getName());
        });
    }

    protected void checkDevice(String deviceId, Callback<BaseResponse<BeanDeviceInfo>> callback){
        RetrofitClient.getInstance().getServiceApi().checkDevice(deviceId).enqueue(callback);
    }
}
